package org.martin.snsrs.services;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.martin.snsrs.beans.Activity;
import org.martin.snsrs.daos.ActivityDao;
import org.martin.snsrs.daos.TagsDao;
import org.martin.snsrs.daos.UserDao;
import org.martin.snsrs.presentation.beans.ActivityBrief;

import com.sun.org.apache.bcel.internal.generic.NEW;

public class ActivityServices {

	private ActivityDao activityDao;
	
	private TagsDao tagsDao;
	
	private UserDao userDao;
	
	public List<Activity> getActivitiesByTag(String tagName){
		List<Activity> activities = new ArrayList<Activity>(); 
		
		return activities;
	}

	public ActivityDao getActivityDao() {
		return activityDao;
	}

	public void setActivityDao(ActivityDao activityDao) {
		this.activityDao = activityDao;
	}

	public TagsDao getTagsDao() {
		return tagsDao;
	}

	public void setTagsDao(TagsDao tagsDao) {
		this.tagsDao = tagsDao;
	}
	
	public List<ActivityBrief> getPresentationActivityBrief(List<Activity> activities) {
		List<ActivityBrief> briefs = new ArrayList<ActivityBrief>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD");
		for(Activity activity : activities){
			ActivityBrief brief = new ActivityBrief();
			brief.setActivityDate(sdf.format(activity.getActivityEndDate().after(new Date())));
			brief.setActivityDesc(activity.getActivityDesc());
			brief.setActivityImagePath(activity.getActivityPic());
			brief.setActivityName(activity.getActivityName());
			brief.setCreateUserName(userDao.getUser(activity.getCreateUser()).getNickname());
			briefs.add(brief);
		}
		return briefs;
	}

	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
}
